package ch4;

import java.util.Scanner;

//回顾：定义一个字符串数组，输入一个字符串,从数组中删除,删除后,后面的往前移动,注意置空的处理...
// 比如字符串为{"aa","bb","cc","ff"},如果bb被删除后,则为{"aa","cc","ff",null}
public class HuiGu {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String[] a = {"aa", "bb", "cc", "dd", "ee", "ff"};
        System.out.println("请输入需要删除的内容：");
        String b = input.next();
        for (int i = 0; i < a.length; i++) {
            if (b.equals(a[i])) {
                for (int j = i; j < a.length - 1; j++)
                    a[j] = a[j + 1];
                a[a.length - 1] = null;
            }
        }
        for (int i = 0; i < a.length; i++) {
            if (a[a.length-1] != null) {
                System.out.println("未找到删除的内容！");
                return;
            }
            System.out.print(a[i] + " ");
        }
    }
}
